package com.example.service.impl;

import com.example.dao.HostDao;
import com.example.entity.Host;
import com.example.service.HostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class HostServiceImpl implements HostService {
    @Autowired
    private HostDao hostDao;
    @Override
    public List<Host> hostList() {
        return hostDao.hostList();
    }

    @Override
    public List<Host> hostListByUserId() {
        return hostDao.hostListByUserId();
    }

    @Override
    public boolean deleteHost(Integer family_id) {
        return hostDao.deleteHost(family_id);
    }

    @Override
    public List<Host> searchHosts(
            String family_name,
            Double minPrice,
            Double maxPrice
    ) {
        return hostDao.searchHosts(family_name, minPrice, maxPrice);
    }

    @Override
    public boolean addHost(Host host) {
        return hostDao.addHost(host) > 0;
    }
    @Override
    public Host getHostById(Integer hostId) {
        return hostDao.getHostById(hostId);
    }
}
